<template>
    <div :id="id">
        <el-switch class="v-switch" v-model="element.data.value" @change="handelChange"></el-switch>
    </div>
</template>

<script>
import register from '@/js/main/register.js';
import bus from '@/js/event/bus.js';

export default {
    props: {
        element: {
            type: Object
        },
        id: {
            type: String
        },
        pageList: {
            type: Array
        },
        mode: {
            type: Number
        }
    },
    data() {
        return {
            eventGroup: {}
        };
    },
    methods: {
        handelChange(val) {
            if (this.mode !== 2 || !this.element.event.length) {
                return;
            }
            bus.elementMouseEvent(this.element, val ? 'on' : 'off');
        }
    },
    created() {
        register.addComponent(this);
    },
    destroyed() {
        register.removeComponent(this);
    }
};
</script>

